
#include <iostream>
#include "Point.h"

/*
ostream& operator<<( ostream &flux, Point const& p )
{
    p.afficher(flux);
    return flux;
}
*/

Point::Point(float x, float y, float z): x(x), y(y), z(z), w(1)
{

}

Point::Point(): x(0), y(0), z(0), w(1) 
{

}

Point::Point( const Point& p) : x(p.x), y(p.y), z(p.z), w(p.w)
{

}

void Point::afficher(std::ostream &flux) const 
{
    flux << "(" << x << "," << y << "," << z << "," << w <<")";
}

float & Point::operator[] (unsigned i)
{
	switch (i) {
		case 0 : return x;
		case 1 : return y;
		case 2 : return z;
		default : return w;
	}
}


 Point Point::operator* (float coeff){
	 Point p(*this);
	 p.x *= coeff;
	 p.y *= coeff;
	 p.z *= coeff;

	 return p;
 }
 
Point Point::operator+ (const Point& point) const{
	Point p(*this);
		
	p.x += point.x;
	p.y += point.y;
	p.z += point.z;

	return p;
}


Point Point::operator- (const Point& point) const
{
	Point p(*this);
		
	p.x -= point.x;
	p.y -= point.y;
	p.z -= point.z;

	return p;
}